package com.example.sonone.controller;


import com.aliyun.oss.OSSClient;
import com.example.sonone.pojo.Stu;
import com.example.sonone.pojo.TokenInfo;
import com.example.sonone.pojo.TrailRecord;
import com.example.sonone.util.OssUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Controller     // 不要用restcontroller
@RequestMapping("oss")
public class TestOssUploadPhoto {


    @Autowired
    private RestTemplate restTemplate;

    @GetMapping("/login")
    public String login() {

        return "login";
    }

    @GetMapping("/donnload")
    public String donnload(HttpServletResponse response, String objectName) throws IOException {
        return OssUtil.getPhotoStream(objectName, response);
//        OssUtil.getStream(objectName, response);
//        return "ok";
    }


    public static void main(String[] args) {
        TrailRecord t=new TrailRecord(); t.setChainId("1");t.setTrailType("1");
        TrailRecord t2=new TrailRecord(); t2.setChainId("2");t2.setTrailType("6");
        TrailRecord t3=new TrailRecord(); t3.setChainId("3");t3.setTrailType("3");
//        TrailRecord t4=new TrailRecord(); t4.setChainId("4");t4.setTrailType("6");

        List<TrailRecord> trailRecordList=new ArrayList<>();
        trailRecordList.add(t);trailRecordList.add(t2);trailRecordList.add(t3);
//        trailRecordList.add(t4);

        boolean hasTask = trailRecordList.stream().anyMatch(a ->
                a.getTrailType().equalsIgnoreCase("6") ||
                a.getTrailType().equalsIgnoreCase("11") ||
                a.getTrailType().equalsIgnoreCase("12")
        );
        System.out.println(hasTask);
    }


}
